package com.tanhua.web;

import com.tanhua.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping(value = "/manage")
public class UserController {

    @Autowired
    private UsersService usersService;

    @GetMapping(value = "/users",name="分页展示用户数据")
    public ResponseEntity findUsers(Integer page,Integer pagesize) throws IOException {
        //根据token将当前用户做删除
        return usersService.findUsers(page,pagesize);
    }


    @GetMapping(value = "/users/{userID}",name="展示点击用户的详情")
    public ResponseEntity findById(@PathVariable("userID") Long userId) throws IOException {
        return usersService.findById(userId);
    }

    @GetMapping(value = "/videos",name="展示点击用户的详情")
    public ResponseEntity findVideos(Integer page,Integer pagesize,Long uid) throws IOException {

        return usersService.findVideos(page,pagesize,uid);
    }


    @GetMapping(value = "/messages",name="查询动态详情")
    public ResponseEntity findMessages(Integer page,Integer pagesize,Long uid,
                                       Integer state) throws IOException {

        return usersService.findMessages(page,pagesize,uid,state);
    }

    @GetMapping(value = "/messages/{id}",name="查询动态详情")
    public ResponseEntity findinfo(@PathVariable("id") String publishId) throws IOException {

        return usersService.findinfo(publishId);
    }

    @GetMapping(value = "/messages/comments",name="查询动态评论")
    public ResponseEntity findComments(Integer page,Integer pagesize,
                                       String messageID) throws IOException {

        return usersService.findComments(page,pagesize,messageID);
    }




}
